<?php
/**
* 定义API抽象类
* 输出通信数据
*/
abstract class Api
{
	const JSON = 'Json';
	const XML = 'Xml';
	/**
	 * 定义工厂方式
	 * @param  string $type [description]
	 * @return class       [description]
	 */
	public static function factory($type = self::JSON)
	{
		$type = isset($_GET['format']) ? $_GET['format'] : $type;
		$resultClass = ucwords($type);
		require_once dirname(__FILE__) . '/Response/' . $type . '.php';
		return new $resultClass;
	}

	abstract function response($code, $message, $data);
}